package ru.nsu.fit.iconveyor.conveyor.channel;

import ru.nsu.fit.iconveyor.engine.exception.ChannelOverflowException;

/**
 * Allows to work with channels without their instances.
 */
public interface ChannelDataProvider {
    /**
     * Polls data from channel with specified id.
     * @param channelId id of channel
     * @param dataClass class of data of channel
     * @param <T> class of data of channel
     * @return data polled from channel
     */
    public <T> T pollFromChannel(String channelId, Class<T> dataClass);

    /**
     * Indicates if specified channel is empty.
     * @param channelId
     * @return
     */
    public boolean isChannelEmpty(String channelId);

    /**
     * Peeks data from channel with specified id.
     * @param channelId
     * @param dataClass class of data of channel
     * @param <T>
     * @return
     */
    public <T> T peekFromChannel(String channelId, Class<T> dataClass);

    /**
     * Adds data to channel with specified id.
     * @param channelId
     * @param data
     * @param <T> class of data of channel
     */
    public <T> void addToChannel(String channelId, T data) throws ChannelOverflowException;
}
